<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>后台登录</title>
<link href="{__PUBLIC_PATH}/common/images/favicon.ico?t={php}echo time();{/php}" rel="icon">
<link rel="stylesheet" href="{__ADMIN_PATH}/assets/libs/layui/css/layui.css?t={php}echo time();{/php}"/>
<link rel="stylesheet" href="{__ADMIN_PATH}/assets/css/admin.css?t={php}echo time();{/php}"/>
<!--[if lt IE 9]>
<script src="{__PUBLIC_PATH}/common/js/admin_html5shiv.min.js"></script>
<script src="{__PUBLIC_PATH}/common/js/admin_respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" href="{__ADMIN_PATH}/assets/css/login.css?t={php}echo time();{/php}">
<script>
    if (window != top) {top.location.replace(location.href);}
</script>
</head>
<body>
<div class="login-wrapper">
    <div class="layui-form">
        <h2>用户登录</h2>
        <div class="layui-form-item layui-input-icon-group">
            <i class="layui-icon layui-icon-username"></i>
            <input class="layui-input" name="username" placeholder="请输入登录账号" autocomplete="off" lay-verType="tips" lay-verify="required" required/>
        </div>
        <div class="layui-form-item layui-input-icon-group">
            <i class="layui-icon layui-icon-password"></i>
            <input class="layui-input" name="password" placeholder="请输入登录密码" type="password" lay-verType="tips" lay-verify="required" required/>
        </div>
        {if $is_vertify ==1}
          <div class="layui-form-item layui-input-icon-group login-captcha-group">
              <i class="layui-icon layui-icon-auz"></i>
              <input class="layui-input" name="code" placeholder="请输入验证码" autocomplete="off" lay-verType="tips" lay-verify="required" required/>
              <img class="login-captcha" src="{:url('/login/captcha')}" id="LAY-user-get-vercode">
          </div>
        {/if}
        <div class="layui-form-item">
          <button class="layui-btn layui-btn-fluid" lay-filter="loginSubmit" lay-submit>登录</button>
        </div>
        <div class="layui-form-item login-oauth-group text-center" style="color:#ccc;text-align:center;">
          <p>PCFCMS版本号：{$version}</p>
          <p>IP：{:request()->ip()} / THINKPHP内核版本：v{:App()->version()}</p>
        </div>
    </div>
</div>
{include file="public/footer"/}
<script>
layui.use(['layer', 'form'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    form.render();//更新渲染
    $(document).keydown(function(event){
      if(event.keyCode ==13){
        $('div button[lay-filter=loginSubmit]').trigger('click');
      }
    });
    // 表单提交
    form.on('submit(loginSubmit)', function (obj) {
        $.ajax({
            url: "{:url('/login/index')}",
            data: obj.field,
            type: "POST",
            dataType: "json",
            success: function(res){
              if (res.code === 0) {
                layer.msg(res.msg, {offset: '15px',icon: 1,time: 1000}, function(){
                  window.location.href = res.data;
                });
              } else {
                $('#LAY-user-get-vercode').trigger('click');
                layer.msg(res.msg, {offset: '15px',icon: 5,time: 1000, title:false});
                return false;
              }
            },
            error : function() {
               layer.msg("未知错误，操作中断！", {offset: '15px',icon: 5,time: 1000, title:false});
            }
        });
    });
    // 图形验证码
    $('.login-captcha').click(function () {
        this.src = "{:url('/login/captcha')}";
        this.src = this.src + '?t=' + (new Date).getTime();
    });
});
</script>
</body>
</html>